<div id="content-outer">
  <div id="content">
    <div id="page-heading"><h1>Register Profile</h1></div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <?php //echo $this->Html->image('../images/shared/side_shadowleft.jpg', array('alt' => '', 'width' => '20', 'height' => '300')); ?>
            </th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized">
                <?php //echo $this->Html->image('../images/shared/side_shadowright.jpg', array('alt' => '', 'width' => '20', 'height' => '300')); ?>
            </th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <div id="content-table-inner">
                    <script type="text/javascript">
                        var is_verify_mobile=0;
                        function send_verify_number(){
                            $('#verify_mobinumber_button').text('Sending ...');
                            $.post('<?php echo $this->Html->url(array('controller'=>'customers','action'=>"send_mobilecode")) ?>',{mobile:$("#mobile_number").val()},function(data){
                                $('#verify_mobinumber_button').text('Verify mobile number');
                            });
                            return false;
                        }
                        function change_mobile(){
                            $('#mobile_number').attr('disabled',false);
                            $('#verify_place').addClass('hidden');
                            return false;
                        }
                        function verify_code_send(){
                            if($("#verify_code").val()){
                                $('#verify_button').text('Checking ...');
                                url='<?php echo $this->Html->url(array('controller'=>'customers','action'=>"verify_code")) ?>/'+$("#verify_code").val();
                                $.get(url,function(data){
                                    if(data=="verify"){
                                        $('#verify_button').text('verify');
                                        $("#is_verify_mobile").val(1);
                                        $('#mobile_number').attr('disabled','disabled');
                                        $('#verify_place').addClass('hidden');
                                        $('#verify_mobinumber_button').addClass('hidden');
                                        $('#verify_status').text("verified");
                                    }else{
                                        $('#verify_button').text('verify');
                                        alert("Wrong code! if you not receive it, please try button 'Re-send'");
                                    }
                                });
                            }else{
                                alert("Please input the code");
                            }
                            return false;
                        }
                        function verify_mobile(){
                            if($("#mobile_number").val()){
                                $('#mobile_number').attr('disabled','disabled');
                                send_verify_number();
                                $('#verify_place').removeClass('hidden');
                            }else{
                                alert("Please fill your mobile number");
                            }
                            return false;
                        }
                        
                    </script>
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr valign="top">
                            <td>
                                <?php 
                                if(isset($invalidate_array)){
                                    $this->Form->validationErrors['Customer']['customer_number'] = $invalidate_array;
                                }
                                if(isset($invalidate_catcha_array)){
                                    $this->Form->validationErrors['Customer']['captcha'] = $invalidate_catcha_array;
                                }
                                echo $this->Form->create("Customer", array('action' => 'register', 'class' => 'form', 'type' => 'file')); ?>
                                <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                                    <?php
                                        echo $this->Session->flash();
                                        echo $this->element("/$lN/form");
                                        echo $this->Form->input('is_verify_mobile',array('type'=>'hidden',"id"=>"is_verify_mobile",'value'=>0));
                                    ?>
                                  <tr>
                                        <th valign="top">Capcha</th>
                                        <td>
                                            <div style="display: inline-block">
                                                <img src="/users/captcha" align="left"/>
                                            </div><br/>
                                            <?php 
                                            echo $this->Form->input('captcha',array('div'=>false,'label'=>false,'class' => 'inp-form med required', 'id' => 'capcha'));
                                            ?> 
                                        </td>
                                        <td></td>
                                    </tr> 
                                  <tr>
                                      <th><span class="red">*</span> Fields are mandatory</th>
                                      <td valign="top">&nbsp;</td>
                                      <td></td>
                                  </tr>
                                    <tr>
                                        <th>&nbsp;</th>
                                        <td valign="top">
                                            <?php echo $this->Form->submit('Submit', array('label' => false, 'div' => false, 'class' => 'submit-button')); ?>
                                                  <?php echo $this->Html->link('Cancel', "/", array('class' => 'cancel-button')); ?>
                                        </td>
                                        <td></td>
                                    </tr>
                                </table>
                            <?php echo $this->Form->end();?>    
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>
                               <?php echo $this->Html->image('../images/shared/blank.gif', array('alt' => 'blank', 'width' => '695', 'height' => '1')); ?>
                            </td>
                            <td></td>
                        </tr>
                    </table>
                    <div class="clear"></div>
                </div>
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>
    <div class="clear">&nbsp;</div>
  </div>
</div>
